x1 <- ggplot()+
  geom_smooth(data = final %>% filter(days < 1), aes(days, violence_range), method = 'loess', color = '#cc6677', fill = "#cc6677", span =.9)+
  geom_smooth(data = final %>% filter(days > -1), aes(days, violence_range), method = 'loess', color = '#cc6677', fill = "#cc6677", span =.55)+
  theme_bw()+
  geom_vline(xintercept = 0, color = 'red', linetype=2)+
  coord_cartesian(ylim = c(0,0.4))+
  scale_x_continuous(breaks = seq(-60,340,20))+
  xlab('Days before/after 2022 Election')+
  ylab('Support Political Violence')+
  theme(axis.text = element_text(size = 8),
        axis.title = element_text(size = 9))

#x1

x2 <- ggplot()+
  geom_smooth(data = final %>% filter(days < 1), aes(days, norms_range), method = 'loess', color = '#56B4E9', fill = "#56B4E9", span =.9)+
  geom_smooth(data = final %>% filter(days > -1), aes(days, norms_range), method = 'loess', color = '#56B4E9', fill = "#56B4E9", span =.3)+
  theme_bw()+
  geom_vline(xintercept = 0, color = 'red', linetype=2)+
  coord_cartesian(ylim = c(0.2,0.6))+
  scale_x_continuous(breaks = seq(-60,340,20))+
  xlab('Days before/after 2022 Election')+
  ylab('Support Norm Violations')+
  theme(axis.text = element_text(size = 8),
        axis.title = element_text(size = 9))
#x2

x3 <- ggplot()+
  geom_smooth(data = final %>% filter(days < 1), aes(days, affpol), method = 'gam', color = '#1c9906', fill = "#1c9906", span =.9)+
  geom_smooth(data = final %>% filter(days > -1), aes(days, affpol), method = 'gam', color = '#1c9906', fill = "#1c9906", span =.5)+
  theme_bw()+
  geom_vline(xintercept = 0, color = 'red', linetype=2)+
  coord_cartesian(ylim = c(20,80))+
  scale_x_continuous(breaks = seq(-60,340,20))+
  xlab('Days before/after 2022 Election')+
  ylab('Affective Polarization')+
  theme(axis.text = element_text(size = 8),
        axis.title = element_text(size = 9))
#x3

final_figure2 <- suppressMessages(ggpubr::ggarrange(x1,x2,x3, ncol = 1, labels = c('A', 'B', 'C'),
                                   font.label = list(size = 9, color = "black", face = "bold")))
suppressMessages(print(final_figure2))
#ggsave(final_figure2, file = 'fig2_final.png', units = 'in', height = 7.8, width = 7.25)